package cn.outsourcing.supermarket.service.impl;

import cn.outsourcing.supermarket.converter.HiolabsGoodsSpecificationConverter;
import cn.outsourcing.supermarket.mapper.HiolabsGoodsSpecificationMapper;
import cn.outsourcing.supermarket.po.HiolabsGoodsSpecification;
import cn.outsourcing.supermarket.service.HiolabsGoodsSpecificationService;
import cn.outsourcing.supermarket.vo.hiolabs.HiolabsGoodsSpecificationVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品对应规格表值表 服务实现类
 *
 * @author gzkemays
 * @since 2021-10-14
 */
@Service
public class HiolabsGoodsSpecificationServiceImpl
    extends ServiceImpl<HiolabsGoodsSpecificationMapper, HiolabsGoodsSpecification>
    implements HiolabsGoodsSpecificationService {
  @Resource HiolabsGoodsSpecificationMapper goodsSpecificationMapper;

  @Override
  public List<HiolabsGoodsSpecificationVO> getGoodsSpecificationVO(Integer goodsId) {
    return HiolabsGoodsSpecificationConverter.INSTANCE.convertToVoList(
        goodsSpecificationMapper.selectList(
            Wrappers.<HiolabsGoodsSpecification>lambdaQuery()
                .eq(HiolabsGoodsSpecification::getGoodsId, goodsId)
                .eq(HiolabsGoodsSpecification::getIsDelete, 0)));
  }
}
